package com.biu.billiards.controller;


import com.biu.billiards.model.vo.coupon.AddCouponVo;
import com.biu.billiards.model.vo.coupon.GetCouponVo;
import com.biu.billiards.model.vo.coupon.UpdateCouponVO;
import com.biu.billiards.model.vo.goods.AddGoodsVo;
import com.biu.billiards.model.vo.goods.GetGoodsVo;
import com.biu.billiards.model.vo.goods.UpdateGoodsVO;
import com.biu.billiards.response.BaseResponse;
import com.biu.billiards.response.RespGenerator;
import com.biu.billiards.service.ICouponService;
import com.biu.billiards.service.IGoodsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xue
 * @since 2023-09-25
 */
@RestController
@RequestMapping()
public class GoodsController {


    @Resource
    private IGoodsService goodsService;



    @ApiOperation(value = "获取商品数据")
    @PostMapping("/getGoodsPage")
    public BaseResponse<Map<String,Object>> getCouponPage(@RequestBody GetGoodsVo getGoodsVo) {
        return RespGenerator.returnOK(goodsService.getGoodsPage(getGoodsVo));
    }


    @ApiOperation(value = "修改商品信息")
    @PutMapping("/updateGoods")
    public BaseResponse<Boolean> updateCoupon(@RequestBody UpdateGoodsVO updateGoodsVO) {
        return RespGenerator.returnOK(goodsService.updateGoods(updateGoodsVO));
    }


    @ApiOperation(value = "新增商品信息")
    @PostMapping("/addGoods")
    public BaseResponse<Boolean> addCoupon(@RequestBody AddGoodsVo addCouponVo) {


        return RespGenerator.returnOK(goodsService.addGoods(addCouponVo));
    }


    @ApiOperation(value = "删除商品信息")
    @DeleteMapping("/deleteGoods")
    public BaseResponse<Boolean> deleteCoupon(@RequestParam("goodsId") Integer goodsId) {
        return RespGenerator.returnOK(goodsService.deleteGoods(goodsId));
    }





}
